package com.eascs.admin.o2o.loanAccount.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.account.account.AccountEntity;
import com.eascs.admin.common.controller.BaseMasterViewController;
import com.eascs.admin.o2o.loan.service.O2oChargeSituationService;
import com.eascs.admin.o2o.loanAccount.vo.O2oCollectFeesVo;
import com.eascs.common.util.StringUtil;
import com.eascs.crm.common.custnew.entity.CustomerEntity;
import com.eascs.crm.common.custnew.service.CustomerService;
import com.eascs.site.view.ViewContext;
import com.eascs.tag.MenuTag;

@Controller
@RequestMapping("/account")
public class PersonalAccountController extends BaseMasterViewController {

	@Autowired
	O2oChargeSituationService o2oChargeSituationService;

	@Reference
	CustomerService customerService;
	


	/**
	 * @Title: index
	 * @Description: 客户账户余额查询
	 * @author 张庆奇
	 * @param vo
	 * @return
	 * @return String
	 * @throws @date
	 *             2017年11月30日 下午5:04:32
	 */
	@RequestMapping("/index")
	public String index(O2oCollectFeesVo vo) {
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "AccountBalance");
		if (StringUtil.isNotBlank(vo.getDocumentNo())) {
			
			String idCard = vo.getDocumentNo().trim();
			CustomerEntity basic = customerService.queryCustomerEntityByIdCard(idCard);
			if (basic != null) {
				ViewContext.put("entity", basic);
				o2oChargeSituationService.getFreezeBalanceByLoanId(basic.getCustomerId());
			}
		}else{
			ViewContext.put("display", "display: none");
		}
		ViewContext.put("vo", vo);
		return "/account/index";
	}
	
	/**
	 * @Title: balanceInfo
	 * @Description: 余额详情页面
	 * @author 张庆奇 
	 * @param id 客户id
	 * @return
	 * @return String
	 * @throws
	 * @date 2017年12月11日 下午3:29:57
	 */
	@RequestMapping("/balance_info")
	public String balanceInfo(String id){
		
		AccountEntity useAccount=	o2oChargeSituationService.queryByLoanId(id,null,"21");
		ViewContext.put("useAccount", useAccount);
		AccountEntity freezeAccount=	o2oChargeSituationService.queryByLoanId(id,null,"22");
		ViewContext.put("freezeAccount", freezeAccount);
		return "/account/balance_info";
	}
	
	/**
	 * @Title: tradeDetail
	 * @Description: 客户账户交易明细
	 * @author 张庆奇
	 * @param id
	 * @return
	 * @return String
	 * @throws
	 * @date 2017年12月11日 下午3:31:23
	 */
	@RequestMapping("/trade_detail")
	public String tradeDetail(String accountId){
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "client_trade_detail");
		ViewContext.put("accountId", accountId);

		return "/account/trade_detail";
	}
	

	

}
